#include <stdio.h>

int a[100];

int partition(int start, int end) {
    int pivot = a[start];
    int left = start;
    int right = end;

    while (left < right) {
        while (left < right && a[right] >= pivot) {
            right--;
        }
        while (left < right && a[left] <= pivot) {
            left++;
        }
        if (left < right) {
            int temp = a[left];
            a[left] = a[right];
            a[right] = temp;
        }
    }
    a[start] = a[left];
    a[left] = pivot;

    return left;
}

void quicksort(int start, int end) {
    int mid;
    if (end > start) {
        mid = partition(start, end);
        quicksort(start, mid - 1);
        quicksort(mid + 1, end);
    }
}

int main() {
    int n;
    printf("请输入数组长度（n <= 100）：");
    scanf("%d", &n);

    printf("请输入%d个整数：", n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }

    quicksort(0, n - 1);

    printf("排序后的数组：");
    for (int i = 0; i < n; i++) {
        printf("%d ", a[i]);
    }
    printf("\n");

    return 0;
}